import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class CautionDialog extends JDialog {
	public CautionDialog(JFrame f, String s) {
		super(f);
		//setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		this.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				closeSelf();
			}
		});

		buildDialog(s);
		
		setTitle("Notice");
		setModal(true);
		setSize(180,120);
		setLocationRelativeTo(null);
		setVisible(true);

	}

	private void buildDialog(String s) {
		// TODO Auto-generated method stub
		JButton btnOk = new JButton("OK");
		JPanel pnldown = new JPanel(new FlowLayout());
		pnldown.add(btnOk);
		btnOk.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				closeSelf();
			}
		});	
		JPanel pnlup = new JPanel(new FlowLayout());
		pnlup.add(new Label(s));
		
		Container cntr = getContentPane();
		cntr.setLayout(new BorderLayout());
		cntr.add(pnlup, BorderLayout.CENTER);
		cntr.add(pnldown, BorderLayout.SOUTH);
		
	}

	protected void closeSelf() {
		// TODO Auto-generated method stub
		dispose();
	}

}
